package com.llb666.shop.items.api.vo;

import com.llb666.shop.items.domain.entity.Items;
import lombok.Data;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * 6个最新商品的简单数据类型
 *
 * @author llb666
 */
@Data
public class SimpleItemVo {

    /**
     * 一级分类
     */
    private Integer rootCatId;
    /**
     * 商品Id
     */
    private String itemId;
    /**
     * 商品名称
     */
    private String itemName;
    /**
     * 商品图片
     */
    private String itemUrl;

    @Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE)
    public interface Converter {
        SimpleItemVo.Converter INSTANCE = Mappers.getMapper(SimpleItemVo.Converter.class);

        @Mappings({
                @Mapping(source = "id", target = "itemId")
        })
        SimpleItemVo do2Vo(Items items);

        List<SimpleItemVo> do2VoList(List<Items> itemsList);

    }

}
